Micron Document
<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Infinite loop</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Infinite_loop"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.pygments.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Infinite_loop rootpage-Infinite_loop skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Infinite loop</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<style data-mw-deduplicate="TemplateStyles:r1236090951">
/* start https://en.wikipedia.org/ */


.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}@media print{body.ns-0 .mw-parser-output .hatnote{display:none!important}}


/* end https://en.wikipedia.org/ */
</style><div role="note" class="hatnote navigation-not-searchable">This article is about the programming term and is not to be confused with <a href="Infinite_Loop_(street)" class="mw-redirect" title="Infinite Loop (street)">Infinite Loop (street)</a> or <a href="Infinite_Loop_(book)" title="Infinite Loop (book)">Infinite Loop (book)</a>.</div>
<div role="note" class="hatnote navigation-not-searchable">"Endless loop" redirects here; not to be confused with <a href="Endless_Loop_(album)" class="mw-redirect" title="Endless Loop (album)">Endless Loop (album)</a>.</div>
<style data-mw-deduplicate="TemplateStyles:r1129693374">
/* start https://en.wikipedia.org/ */


.mw-parser-output .hlist dl,.mw-parser-output .hlist ol,.mw-parser-output .hlist ul{margin:0;padding:0}.mw-parser-output .hlist dd,.mw-parser-output .hlist dt,.mw-parser-output .hlist li{margin:0;display:inline}.mw-parser-output .hlist.inline,.mw-parser-output .hlist.inline dl,.mw-parser-output .hlist.inline ol,.mw-parser-output .hlist.inline ul,.mw-parser-output .hlist dl dl,.mw-parser-output .hlist dl ol,.mw-parser-output .hlist dl ul,.mw-parser-output .hlist ol dl,.mw-parser-output .hlist ol ol,.mw-parser-output .hlist ol ul,.mw-parser-output .hlist ul dl,.mw-parser-output .hlist ul ol,.mw-parser-output .hlist ul ul{display:inline}.mw-parser-output .hlist .mw-empty-li{display:none}.mw-parser-output .hlist dt::after{content:": "}.mw-parser-output .hlist dd::after,.mw-parser-output .hlist li::after{content:" · ";font-weight:bold}.mw-parser-output .hlist dd:last-child::after,.mw-parser-output .hlist dt:last-child::after,.mw-parser-output .hlist li:last-child::after{content:none}.mw-parser-output .hlist dd dd:first-child::before,.mw-parser-output .hlist dd dt:first-child::before,.mw-parser-output .hlist dd li:first-child::before,.mw-parser-output .hlist dt dd:first-child::before,.mw-parser-output .hlist dt dt:first-child::before,.mw-parser-output .hlist dt li:first-child::before,.mw-parser-output .hlist li dd:first-child::before,.mw-parser-output .hlist li dt:first-child::before,.mw-parser-output .hlist li li:first-child::before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child::after,.mw-parser-output .hlist dd dt:last-child::after,.mw-parser-output .hlist dd li:last-child::after,.mw-parser-output .hlist dt dd:last-child::after,.mw-parser-output .hlist dt dt:last-child::after,.mw-parser-output .hlist dt li:last-child::after,.mw-parser-output .hlist li dd:last-child::after,.mw-parser-output .hlist li dt:last-child::after,.mw-parser-output .hlist li li:last-child::after{content:")";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li::before{content:" "counter(listitem)"\a0 "}.mw-parser-output .hlist dd ol>li:first-child::before,.mw-parser-output .hlist dt ol>li:first-child::before,.mw-parser-output .hlist li ol>li:first-child::before{content:" ("counter(listitem)"\a0 "}


/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1246091330">
/* start https://en.wikipedia.org/ */


.mw-parser-output .sidebar{width:22em;float:right;clear:right;margin:0.5em 0 1em 1em;background:var(--background-color-neutral-subtle,#f8f9fa);border:1px solid var(--border-color-base,#a2a9b1);padding:0.2em;text-align:center;line-height:1.4em;font-size:88%;border-collapse:collapse;display:table}body.skin-minerva .mw-parser-output .sidebar{display:table!important;float:right!important;margin:0.5em 0 1em 1em!important}.mw-parser-output .sidebar-subgroup{width:100%;margin:0;border-spacing:0}.mw-parser-output .sidebar-left{float:left;clear:left;margin:0.5em 1em 1em 0}.mw-parser-output .sidebar-none{float:none;clear:both;margin:0.5em 1em 1em 0}.mw-parser-output .sidebar-outer-title{padding:0 0.4em 0.2em;font-size:125%;line-height:1.2em;font-weight:bold}.mw-parser-output .sidebar-top-image{padding:0.4em}.mw-parser-output .sidebar-top-caption,.mw-parser-output .sidebar-pretitle-with-top-image,.mw-parser-output .sidebar-caption{padding:0.2em 0.4em 0;line-height:1.2em}.mw-parser-output .sidebar-pretitle{padding:0.4em 0.4em 0;line-height:1.2em}.mw-parser-output .sidebar-title,.mw-parser-output .sidebar-title-with-pretitle{padding:0.2em 0.8em;font-size:145%;line-height:1.2em}.mw-parser-output .sidebar-title-with-pretitle{padding:0.1em 0.4em}.mw-parser-output .sidebar-image{padding:0.2em 0.4em 0.4em}.mw-parser-output .sidebar-heading{padding:0.1em 0.4em}.mw-parser-output .sidebar-content{padding:0 0.5em 0.4em}.mw-parser-output .sidebar-content-with-subgroup{padding:0.1em 0.4em 0.2em}.mw-parser-output .sidebar-above,.mw-parser-output .sidebar-below{padding:0.3em 0.8em;font-weight:bold}.mw-parser-output .sidebar-collapse .sidebar-above,.mw-parser-output .sidebar-collapse .sidebar-below{border-top:1px solid #aaa;border-bottom:1px solid #aaa}.mw-parser-output .sidebar-navbar{text-align:right;font-size:115%;padding:0 0.4em 0.4em}.mw-parser-output .sidebar-list-title{padding:0 0.4em;text-align:left;font-weight:bold;line-height:1.6em;font-size:105%}.mw-parser-output .sidebar-list-title-c{padding:0 0.4em;text-align:center;margin:0 3.3em}@media(max-width:640px){body.mediawiki .mw-parser-output .sidebar{width:100%!important;clear:both;float:none!important;margin-left:0!important;margin-right:0!important}}body.skin--responsive .mw-parser-output .sidebar a>img{max-width:none!important}@media screen{html.skin-theme-clientpref-night .mw-parser-output .sidebar:not(.notheme) .sidebar-list-title,html.skin-theme-clientpref-night .mw-parser-output .sidebar:not(.notheme) .sidebar-title-with-pretitle{background:transparent!important}html.skin-theme-clientpref-night .mw-parser-output .sidebar:not(.notheme) .sidebar-title-with-pretitle a{color:var(--color-progressive)!important}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .sidebar:not(.notheme) .sidebar-list-title,html.skin-theme-clientpref-os .mw-parser-output .sidebar:not(.notheme) .sidebar-title-with-pretitle{background:transparent!important}html.skin-theme-clientpref-os .mw-parser-output .sidebar:not(.notheme) .sidebar-title-with-pretitle a{color:var(--color-progressive)!important}}@media print{body.ns-0 .mw-parser-output .sidebar{display:none!important}}


/* end https://en.wikipedia.org/ */
</style><table class="sidebar nomobile nowraplinks"><tbody><tr><th class="sidebar-title"><a href="Control_flow#Loops" title="Control flow">Loop constructs</a></th></tr><tr><td class="sidebar-content">
<div class="hlist">
<ul><li><a href="Do_while_loop" title="Do while loop">Do while loop</a></li>
<li><a href="While_loop" title="While loop">While loop</a></li>
<li><a href="For_loop" title="For loop">For loop</a></li>
<li><a href="Foreach_loop" title="Foreach loop">Foreach loop</a></li>

<li><a href="Control_flow" title="Control flow">Control flow</a></li></ul>
</div></td>
</tr><tr><td class="sidebar-navbar"><style data-mw-deduplicate="TemplateStyles:r1239400231">
/* start https://en.wikipedia.org/ */


.mw-parser-output .navbar{display:inline;font-size:88%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar a>span,.mw-parser-output .navbar a>abbr{text-decoration:inherit}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}html.skin-theme-clientpref-night .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}@media(prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}}@media print{.mw-parser-output .navbar{display:none!important}}


/* end https://en.wikipedia.org/ */
</style></td></tr></tbody></table>
<p>In <a href="Computer_programming" title="Computer programming">computer programming</a>, an <b>infinite loop</b> (or <b>endless loop</b>)<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> is a sequence of instructions that, as written, will continue endlessly, unless an external intervention occurs, such as turning off power via a switch or pulling a plug. It may be intentional.
</p><p>There is no general algorithm to determine whether a computer program contains an infinite loop or not; this is the <a href="Halting_problem" title="Halting problem">halting problem</a>.
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="Overview">Overview</h2></div>
<p>This differs from "a type of computer program that runs the same instructions continuously until it is either stopped or interrupted".<sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup> Consider the following <a href="Pseudocode" title="Pseudocode">pseudocode</a>:
</p>
<div class="mw-highlight mw-highlight-lang-lua mw-content-ltr" dir="ltr"><pre><span class="nv">how_many</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span>
<span class="kr">while</span><span class="w"> </span><span class="nf">is_there_more_data</span><span class="p">()</span><span class="w"> </span><span class="kr">do</span>
<span class="w"> </span><span class="nv">how_many</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nv">how_many</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span>
<span class="kr">end</span>
<span class="nv">display</span><span class="w"> </span><span class="s2">"the number of items counted = "</span><span class="w"> </span><span class="nv">how_many</span>
</pre></div>
<p><i>The same instructions</i> were run <i>continuously until it was stopped or interrupted</i> . . . by the <i>FALSE</i> returned at some point by the function <i>is_there_more_data</i>.
</p><p>By contrast, the following loop will not end by itself:
</p>
<div class="mw-highlight mw-highlight-lang-lua mw-content-ltr" dir="ltr"><pre><span class="nv">birds</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span>
<span class="nv">fish</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span>
<span class="kr">while</span><span class="w"> </span><span class="nv">birds</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nv">fish</span><span class="w"> </span><span class="o">&gt;</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="kr">do</span>
<span class="w"> </span><span class="nv">birds</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nv">birds</span>
<span class="w"> </span><span class="nv">fish</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nv">fish</span>
<span class="kr">end</span>
</pre></div>
<p><i>birds</i> will alternate being 1 or 2, while <i>fish</i> will alternate being 2 or 1. The loop will not stop unless an external intervention occurs ("pull the plug").
</p>
<div class="mw-heading mw-heading2"><h2 id="Details">Details</h2></div>
<p>An <i>infinite loop</i> is a sequence of instructions in a <a href="Computer_program" title="Computer program">computer program</a> which loops endlessly, either due to the <a href="Control_flow#Loops" title="Control flow">loop</a> having no terminating condition,<sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> having one that can never be met, or one that causes the loop to start over. In older <a href="Operating_system" title="Operating system">operating systems</a> with <a href="Cooperative_multitasking" title="Cooperative multitasking">cooperative multitasking</a>,<sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup> infinite loops normally caused the entire system to become unresponsive. With the now-prevalent preemptive multitasking model, infinite loops usually cause the program to consume all available processor time, but can usually be terminated by a user. <a href="Busy_waiting" title="Busy waiting">Busy wait</a> loops are also sometimes called "infinite loops". Infinite loops are one possible cause for a computer <a href="Hang_(computing)" title="Hang (computing)">hanging or freezing</a>; others include <a href="Thrashing_(computer_science)" title="Thrashing (computer science)">thrashing</a>, <a href="Deadlock_(computer_science)" title="Deadlock (computer science)">deadlock</a>, and <a href="Segmentation_fault" title="Segmentation fault">access violations</a>.
</p>
<div class="mw-heading mw-heading2"><h2 id="Intended_vs_unintended_looping">Intended vs unintended looping</h2></div>
<p>Looping is repeating a set of instructions until a specific condition is met. An infinite loop occurs when the condition will never be met due to some inherent characteristic of the loop.
</p>
<div class="mw-heading mw-heading3"><h3 id="Intentional_looping">Intentional looping</h3></div>
<p>There are a few situations when this is desired behavior. For example, the games on cartridge-based game consoles typically have no exit condition in their main loop, as there is no operating system for the program to exit to; the loop runs until the console is powered off.
</p><p>Modern interactive computers require that the computer constantly be monitoring for user input or device activity, so at some fundamental level there is an infinite processing <a href="Idle_loop" class="mw-redirect" title="Idle loop">idle loop</a> that must continue until the device is turned off or reset. In the <a href="Apollo_Guidance_Computer" title="Apollo Guidance Computer">Apollo Guidance Computer</a>, for example, this outer loop was contained in the Exec program,<sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup> and if the computer had absolutely no other work to do, it would loop run a dummy job that would simply turn off the "computer activity" indicator light.
</p><p>Modern computers also typically do not halt the processor or motherboard circuit-driving clocks when they crash. Instead they fall back to an error condition displaying messages to the operator (such as the <a href="Blue_screen_of_death" title="Blue screen of death">blue screen of death</a>), and enter an infinite loop waiting for the user to either respond to a prompt to continue, or reset the device.
</p>
<div class="mw-heading mw-heading4"><h4 id="Spinlocks">Spinlocks</h4></div>
<p><a href="Spinlock" title="Spinlock">Spinlocks</a> are low-level synchronization mechanisms used in concurrent programming to protect shared resources. Unlike traditional locks that put a thread to sleep when it can't acquire the lock, spinlocks repeatedly "spin" in an infinite loop until the lock becomes available. This intentional infinite looping is a deliberate design choice aimed at minimizing the time a thread spends waiting for the lock and avoiding the overhead of higher level synchronisation mechanisms such as <a href="Lock_(computer_science)" title="Lock (computer science)">mutexes</a>.
</p>
<div class="mw-heading mw-heading4"><h4 id="Multi-threading">Multi-threading</h4></div>
<p>In multi-threaded programs some threads can be executing inside infinite loops without causing the entire program to be stuck in an infinite loop. If the main thread exits, all threads of the process are forcefully stopped, thus all execution ends and the process/program terminates. The threads inside the infinite loops can perform "housekeeping" tasks or they can be in a blocked state waiting for input (from socket/queue) and resume execution every time input is received.
</p>
<div class="mw-heading mw-heading3"><h3 id="Unintentional_looping">Unintentional looping</h3></div>

<p>Most often, the term is used for those situations when this is not the intended result; that is, when this is a <a href="Software_bug" title="Software bug">bug</a>.<sup id="cite_ref-7" class="reference"><a href="#cite_note-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup> Such errors are most common by novice programmers, but can be made by experienced programmers also, because their causes can be quite subtle.
</p><p>One common cause, for example, is that a programmer intends to iterate over sequence of nodes in a <a href="Data_structure" title="Data structure">data structure</a> such as a <a href="Linked_list" title="Linked list">linked list</a> or <a href="Tree_(data_structure)" class="mw-redirect" title="Tree (data structure)">tree</a>, executing the loop code once for each node. Improperly formed links can create a <i>reference loop</i> in the data structure, where one node links to another that occurs earlier in the sequence. This makes part of the data structure into a <a href="Ring_(data_structure)" class="mw-redirect" title="Ring (data structure)">ring</a>, causing naive code to loop forever.
</p><p>While most infinite loops can be found by close inspection of the code, there is no general method to determine whether a given program will ever halt or will run forever; this is the <a href="Undecidable_problem" title="Undecidable problem">undecidability</a> of the <a href="Halting_problem" title="Halting problem">halting problem</a>.<sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="Interruption">Interruption</h2></div>
<p>As long as the system is responsive, infinite loops can often be interrupted by sending a signal to the process (such as <a href="SIGINT_(POSIX)" class="mw-redirect" title="SIGINT (POSIX)">SIGINT</a> in Unix), or an <a href="Interrupt" title="Interrupt">interrupt</a> to the processor, causing the current process to be aborted. This can be done in a <a href="Task_manager" title="Task manager">task manager</a>, in a terminal with the <a href="Control-C" title="Control-C">Control-C</a> command,<sup id="cite_ref-9" class="reference"><a href="#cite_note-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup> or by using the <a href="Kill_(command)" title="Kill (command)">kill</a> command or <a href="System_call" title="System call">system call</a>. However, this does not always work, as the process may not be responding to signals or the processor may be in an uninterruptible state, such as in the <a href="Cyrix_coma_bug" title="Cyrix coma bug">Cyrix coma bug</a> (caused by overlapping uninterruptible instructions in an <a href="Instruction_pipeline" class="mw-redirect" title="Instruction pipeline">instruction pipeline</a>). In some cases other signals such as <a href="SIGKILL" class="mw-redirect" title="SIGKILL">SIGKILL</a> can work, as they do not require the process to be responsive, while in other cases the loop cannot be terminated short of system shutdown.
</p>
<div class="mw-heading mw-heading2"><h2 id="Language_support">Language support</h2></div>
<div role="note" class="hatnote navigation-not-searchable">See also: <a href="Control_flow" title="Control flow">Control flow</a></div>
<p>Infinite loops can be implemented using various <a href="Control_flow" title="Control flow">control flow</a> constructs. Most commonly, in unstructured programming this is jump back up (<a href="Goto" title="Goto">goto</a>), while in <a href="Structured_programming" title="Structured programming">structured programming</a> this is an indefinite loop (<a href="While_loop" title="While loop">while loop</a>) set to never end, either by omitting the condition or explicitly setting it to true, as <code>while (true) ...</code>.
</p><p>Some languages have special constructs for infinite loops, typically by omitting the condition from an indefinite loop. Examples include Ada (<code>loop ... end loop</code>),<sup id="cite_ref-10" class="reference"><a href="#cite_note-10"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup> Fortran (<code>DO ... END DO</code>), Go (<code>for { ... }</code>), Ruby (<code>loop do ... end</code>), and Rust (<code>loop { ... }</code>).
</p>
<div class="mw-heading mw-heading2"><h2 id="Examples_of_intentional_infinite_loops">Examples of intentional infinite loops</h2></div>
<p>A simple example (in <a href="C_(programming_language)" title="C (programming language)">C</a>):
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;stdio.h&gt;</span>

<span class="kt">int</span><span class="w"> </span><span class="nf">main</span><span class="p">()</span>
<span class="p">{</span>
<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(;;)</span><span class="w"> </span><span class="c1">// or equivalently, while (1)</span>
<span class="w"> </span><span class="n">printf</span><span class="p">(</span><span class="s">"Infinite Loop</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span><span class="w"> </span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
<p>The form <code>for (;;)</code> for an infinite loop is traditional, appearing in the standard reference <i><a href="The_C_Programming_Language" title="The C Programming Language">The C Programming Language</a></i>, and is often punningly pronounced "forever".<sup id="cite_ref-11" class="reference"><a href="#cite_note-11"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup>
</p><p>This is a loop that will print "Infinite Loop" without halting.
</p><p>A similar example in 1980s-era <a href="BASIC_programming_language" class="mw-redirect" title="BASIC programming language">BASIC</a>:
</p>
<div class="mw-highlight mw-highlight-lang-basic mw-content-ltr" dir="ltr"><pre><span class="nl">10</span><span class="w"> </span><span class="kr">PRINT</span><span class="w"> </span><span class="s2">"INFINITE LOOP"</span>
<span class="nl">20</span><span class="w"> </span><span class="kr">GOTO</span><span class="w"> </span><span class="nl">10</span>
</pre></div>
<p>A similar example in <a href="MS-DOS" title="MS-DOS">MS-DOS</a> compatible batch files:
</p>
<div class="mw-highlight mw-highlight-lang-bat mw-content-ltr" dir="ltr"><pre><span class="p">:</span><span class="nl">A</span>
<span class="k">echo</span> Infinite Loop
<span class="k">goto</span> <span class="p">:</span><span class="nl">A</span>
</pre></div>
<p>In <a href="Java_(programming_language)" title="Java (programming language)">Java</a>:
</p>
<div class="mw-highlight mw-highlight-lang-java mw-content-ltr" dir="ltr"><pre><span class="k">while</span><span class="w"> </span><span class="p">(</span><span class="kc">true</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">System</span><span class="p">.</span><span class="na">out</span><span class="p">.</span><span class="na">println</span><span class="p">(</span><span class="s">"Infinite Loop"</span><span class="p">);</span>
<span class="p">}</span>
</pre></div>
<p>The while loop never terminates because its condition is always true.
</p><p>In <a href="Bourne_Again_Shell" class="mw-redirect" title="Bourne Again Shell">Bourne Again Shell</a>:
</p>
<div class="mw-highlight mw-highlight-lang-bash mw-content-ltr" dir="ltr"><pre><span class="k">for</span><span class="w"> </span><span class="o">((</span><span class="p">;;</span><span class="o">))</span><span class="p">;</span><span class="w"> </span><span class="k">do</span>
<span class="w"> </span><span class="nb">echo</span><span class="w"> </span><span class="s2">"Infinite Loop"</span>
<span class="k">done</span>
</pre></div>
<p>In <a href="Rust_(programming_language)" title="Rust (programming language)">Rust</a>:
</p>
<div class="mw-highlight mw-highlight-lang-rust mw-content-ltr" dir="ltr"><pre><span class="k">loop</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="fm">println!</span><span class="p">(</span><span class="s">"Infinite loop"</span><span class="p">);</span>
<span class="p">}</span>
</pre></div>
<div class="mw-heading mw-heading2"><h2 id="Examples_of_unintentional_infinite_loops">Examples of unintentional infinite loops</h2></div>
<div class="mw-heading mw-heading3"><h3 id="Mathematical_errors">Mathematical errors</h3></div>
<p>Here is one example of an infinite loop in <a href="Visual_Basic" title="Visual Basic">Visual Basic</a>:
</p>
<div class="mw-highlight mw-highlight-lang-vbnet mw-content-ltr" dir="ltr"><pre><span class="k">dim</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="ow">as</span><span class="w"> </span><span class="kt">integer</span>
<span class="k">do</span><span class="w"> </span><span class="k">while</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="mi">5</span>
<span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span>
<span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span>
<span class="k">loop</span>
</pre></div>
<p>This creates a situation where <code>x</code> will never be greater than 5, since at the start of the loop code, <code>x</code> is assigned the value of 1 (regardless of any previous value) before it is changed to <code>x</code> + 1. Thus the loop will always result in <code>x</code> = 2 and will never break. This could be fixed by moving the <code>x = 1</code> instruction outside the loop so that its initial value is set only once.
</p><p>In some languages, programmer confusion about mathematical symbols may lead to an unintentional infinite loop. For example, here is a snippet in <a href="C_(programming_language)" title="C (programming language)">C</a>:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;stdio.h&gt;</span>

<span class="kt">int</span><span class="w"> </span><span class="nf">main</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span>
<span class="p">{</span>
<span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span>
<span class="w"> </span><span class="k">while</span><span class="w"> </span><span class="p">(</span><span class="n">a</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="mi">10</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">printf</span><span class="p">(</span><span class="s">"%d</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span><span class="w"> </span><span class="n">a</span><span class="p">);</span>
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">a</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">5</span><span class="p">)</span>
<span class="w"> </span><span class="n">printf</span><span class="p">(</span><span class="s">"a equals 5!</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span>
<span class="w"> </span><span class="n">a</span><span class="o">++</span><span class="p">;</span>
<span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
<p>The expected output is the numbers 0 through 9, with an interjected "a equals 5!" between 5 and 6. However, in the line "<code>if (a = 5)</code>" above, the = (assignment) operator was confused with the == (equality test) operator. Instead, this will assign the value of 5 to <code>a</code> at this point in the program. Thus, <code>a</code> will never be able to advance to 10, and this loop cannot terminate.
</p>
<div class="mw-heading mw-heading3"><h3 id="Rounding_errors">Rounding errors</h3></div>
<table style="float:right; border: 1px solid grey;">

<tbody><tr>
<td><i>C output on an <a href="AMD_Turion" title="AMD Turion">AMD Turion</a> processor:</i>
</td></tr>
<tr>
<td>x = 0.10000000149011611938
</td></tr>
<tr>
<td>x = 0.20000000298023223877
</td></tr>
<tr>
<td>x = 0.30000001192092895508
</td></tr>
<tr>
<td>x = 0.40000000596046447754
</td></tr>
<tr>
<td>x = 0.50000000000000000000
</td></tr>
<tr>
<td>x = 0.60000002384185791016
</td></tr>
<tr>
<td>x = 0.70000004768371582031
</td></tr>
<tr>
<td>x = 0.80000007152557373047
</td></tr>
<tr>
<td>x = 0.90000009536743164062
</td></tr>
<tr>
<td>x = 1.00000011920928955078
</td></tr>
<tr>
<td>x = 1.10000014305114746094
</td></tr>
<tr>
<td>x = 1.20000016689300537109
</td></tr>
<tr>
<td>...
</td></tr></tbody></table>
<p>Unexpected behavior in evaluating the terminating condition can also cause this problem. Here is an example in <a href="C_(programming_language)" title="C (programming language)">C</a>:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="kt">float</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0.1</span><span class="p">;</span>
<span class="k">while</span><span class="w"> </span><span class="p">(</span><span class="n">x</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="mf">1.1</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">printf</span><span class="p">(</span><span class="s">"x = %22.20f</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span><span class="w"> </span><span class="n">x</span><span class="p">);</span>
<span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="mf">0.1</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
<p>On some systems, this loop will execute ten times as expected, but on other systems it will never terminate. The problem is that the loop terminating condition <code>(x&nbsp;!= 1.1)</code> tests for exact equality of two <a href="Floating_point" class="mw-redirect" title="Floating point">floating point</a> values, and the way floating point values are represented in many computers will make this test fail, because they cannot represent the value 0.1 exactly, thus introducing rounding errors on each increment (cf. box).
</p><p>The same can happen in <a href="Python_(programming_language)" title="Python (programming language)">Python</a>:
</p>
<div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span class="n">x</span> <span class="o">=</span> <span class="mf">0.1</span>
<span class="k">while</span> <span class="n">x</span> <span class="o">!=</span> <span class="mi">1</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="n">x</span> <span class="o">+=</span> <span class="mf">0.1</span>
</pre></div>
<p>Because of the likelihood of tests for equality or not-equality failing unexpectedly, it is safer to use greater-than or less-than tests when dealing with floating-point values. For example, instead of testing whether <code>x</code> equals 1.1, one might test whether <code>(x &lt;= 1.0)</code>, or <code>(x &lt; 1.1)</code>, either of which would be certain to exit after a finite number of iterations. Another way to fix this particular example would be to use an <a href="Integer_(computer_science)" title="Integer (computer science)">integer</a> as a <a href="Control_flow" title="Control flow">loop index</a>, counting the number of iterations that have been performed.
</p><p>A similar problem occurs frequently in <a href="Numerical_analysis" title="Numerical analysis">numerical analysis</a>: in order to compute a certain result, an iteration is intended to be carried out until the error is smaller than a chosen tolerance. However, because of rounding errors during the iteration, the specified tolerance can never be reached, resulting in an infinite loop.
</p>
<div class="mw-heading mw-heading2"><h2 id="Multi-party_loops">Multi-party loops</h2></div>
<p>An infinite loop may be caused by several entities interacting. Consider a server that always replies with an <a href="Error_message" title="Error message">error message</a> if it does not understand the request. Even if there is no possibility for an infinite loop within the server itself, a system comprising two of them (<i>A</i> and <i>B</i>) may loop endlessly: if <i>A</i> receives a message of unknown type from <i>B</i>, then <i>A</i> replies with an error message to <i>B</i>; if <i>B</i> does not understand the error message, it replies to <i>A</i> with its own error message; if <i>A</i> does not understand the error message from <i>B</i>, it sends yet another error message, and so on.
</p><p>One common example of such situation is an email loop. An example of an email loop is if someone receives mail from a no reply inbox, but their auto-response is on. They will reply to the no reply inbox, triggering the "this is a no reply inbox" response. This will be sent to the user, who then sends an auto reply to the no-reply inbox, and so on and so forth.
</p>
<div class="mw-heading mw-heading2"><h2 id="Pseudo-infinite_loops">Pseudo-infinite loops</h2></div>
<p>A pseudo-infinite loop is a loop that appears infinite but is really just a very long loop.
</p>
<div class="mw-heading mw-heading3"><h3 id="Very_large_numbers">Very large numbers</h3></div>
<p>An example in <a href="Bash_(Unix_shell)" title="Bash (Unix shell)">bash</a>:
</p>
<div class="mw-highlight mw-highlight-lang-bash mw-content-ltr" dir="ltr"><pre><span class="k">for</span><span class="w"> </span>x<span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="k">$(</span>seq<span class="w"> </span><span class="m">1000000000</span><span class="k">)</span><span class="p">;</span><span class="w"> </span><span class="k">do</span>
<span class="c1">#loop code</span>
<span class="k">done</span>
</pre></div>
<div class="mw-heading mw-heading3"><h3 id="Impossible_termination_condition">Impossible termination condition</h3></div>
<p>An example <a href="For_loop" title="For loop">for loop</a> in <a href="C_(programming_language)" title="C (programming language)">C</a>:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="kt">unsigned</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="p">;</span>
<span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="cm">/* loop code */</span>
<span class="p">}</span>
</pre></div>
<p>It appears that this will go on indefinitely, but in fact the value of <code>i</code> will eventually reach the maximum value storable in an <code>unsigned int</code> and adding 1 to that number will wrap-around to 0, breaking the loop. The actual limit of <code>i</code> depends on the details of the system and <a href="Compiler" title="Compiler">compiler</a> used. With <a href="Arbitrary-precision_arithmetic" title="Arbitrary-precision arithmetic">arbitrary-precision arithmetic</a>, this loop would continue until the computer's <a href="Memory_(computers)" class="mw-redirect" title="Memory (computers)">memory</a> could no longer hold <code>i</code>. If <code>i</code> was a signed integer, rather than an unsigned integer, overflow would be undefined. In this case, the compiler could optimize the code into an infinite loop.
</p>
<div class="mw-heading mw-heading3"><h3 id="Infinite_recursion">Infinite recursion</h3></div>
<div role="note" class="hatnote navigation-not-searchable">Main article: <a href="Recursion_(computer_science)#Infinite_recursion" title="Recursion (computer science)">Recursion (computer science) §&nbsp;Infinite recursion</a></div>
<p>Infinite recursion is a special case of an infinite loop that is caused by <a href="Recursion_(computer_science)" title="Recursion (computer science)">recursion</a>.
</p><p>The following example in <a href="Visual_Basic_for_Applications" title="Visual Basic for Applications">Visual Basic for Applications</a> (VBA) returns a <a href="Stack_overflow" title="Stack overflow">stack overflow</a> error:
</p>
<div class="mw-highlight mw-highlight-lang-vbscript mw-content-ltr" dir="ltr"><pre><span class="kd">Sub</span><span class="w"> </span><span class="nf">Test1</span><span class="p">()</span>
<span class="w"> </span><span class="k">Call</span><span class="w"> </span><span class="n">Test1</span>
<span class="k">End</span><span class="w"> </span><span class="k">Sub</span>
</pre></div>
<div class="mw-heading mw-heading3"><h3 id="Break_statement">Break statement</h3></div>
<p>A "<code>while (true)</code>" loop looks infinite at first glance, but there may be a way to escape the loop through a <a href="Break_statement" class="mw-redirect" title="Break statement">break statement</a> or <a href="Return_statement" title="Return statement">return statement</a>.
Example in <a href="PHP" title="PHP">PHP</a>:
</p>
<div class="mw-highlight mw-highlight-lang-php mw-content-ltr" dir="ltr"><pre><span class="k">while</span> <span class="p">(</span><span class="k">true</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nv">$foo</span><span class="o">-&gt;</span><span class="na">bar</span><span class="p">())</span> <span class="p">{</span>
<span class="k">return</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
<div class="mw-heading mw-heading3"><h3 id="Alderson_loop">Alderson loop</h3></div>
<p><i>Alderson loop</i> is a rare slang or <a href="The_Jargon_File" class="mw-redirect" title="The Jargon File">jargon</a> term for an infinite loop where there is an exit condition available, but inaccessible in an implementation of the code, typically due to a programmer error. These are most common and visible while <a href="Debugging" title="Debugging">debugging</a> <a href="User_interface" title="User interface">user interface</a> code.
</p><p>A C-like pseudocode example of an Alderson loop, where the program is supposed to sum numbers given by the user until zero is given, but where the wrong operator is used:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="kt">int</span><span class="w"> </span><span class="n">sum</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span>
<span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="p">;</span>
<span class="k">while</span><span class="w"> </span><span class="p">(</span><span class="nb">true</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">printf</span><span class="p">(</span><span class="s">"Input a number to add to the sum or 0 to quit"</span><span class="p">);</span>
<span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">getUserInput</span><span class="p">();</span>
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">i</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mi">0</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// if i times 0 is true, add i to the sum. Note: ZERO means FALSE, Non-Zero means TRUE. "i * 0" is ZERO (FALSE)!</span>
<span class="w"> </span><span class="n">sum</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">i</span><span class="p">;</span><span class="w"> </span><span class="c1">// sum never changes because (i * 0) is 0 for any i; it would change if we had&nbsp;!= in the condition instead of *</span>
<span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">sum</span><span class="w"> </span><span class="o">&gt;</span><span class="w"> </span><span class="mi">100</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">break</span><span class="p">;</span><span class="w"> </span><span class="c1">// terminate the loop; exit condition exists but is never reached because sum is never added to</span>
<span class="w"> </span><span class="p">}</span>
<span class="p">}</span>
</pre></div>
<p>The term allegedly received its name from a programmer (whose last name is Alderson) who in 1996<sup id="cite_ref-12" class="reference"><a href="#cite_note-12"><span class="cite-bracket">[</span>12<span class="cite-bracket">]</span></a></sup> had coded a <a href="Modal_window" title="Modal window">modal</a> <a href="Dialog_box" title="Dialog box">dialog box</a> in <a href="Microsoft_Access" title="Microsoft Access">Microsoft Access</a> without either an OK or Cancel button, thereby disabling the entire program whenever the box came up.<sup id="cite_ref-13" class="reference"><a href="#cite_note-13"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1266661725">
/* start https://en.wikipedia.org/ */


.mw-parser-output .portalbox{padding:0;margin:0.5em 0;display:table;box-sizing:border-box;max-width:175px;list-style:none}.mw-parser-output .portalborder{border:1px solid var(--border-color-base,#a2a9b1);padding:0.1em;background:var(--background-color-neutral-subtle,#f8f9fa)}.mw-parser-output .portalbox-entry{display:table-row;font-size:85%;line-height:110%;height:1.9em;font-style:italic;font-weight:bold}.mw-parser-output .portalbox-image{display:table-cell;padding:0.2em;vertical-align:middle;text-align:center}.mw-parser-output .portalbox-link{display:table-cell;padding:0.2em 0.2em 0.2em 0.3em;vertical-align:middle}@media(min-width:720px){.mw-parser-output .portalleft{margin:0.5em 1em 0.5em 0}.mw-parser-output .portalright{clear:right;float:right;margin:0.5em 0 0.5em 1em}}


/* end https://en.wikipedia.org/ */
</style>
<ul><li><a href="Cycle_detection" title="Cycle detection">Cycle detection</a></li>
<li><a href="Divergence_(computer_science)" title="Divergence (computer science)">Divergence (computer science)</a></li>
<li><a href="Fork_bomb" title="Fork bomb">Fork bomb</a> (an infinite loop is one of two key components)</li>
<li><a href="Infinite_regress" title="Infinite regress">Infinite regress</a></li></ul>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */


.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}


/* end https://en.wikipedia.org/ */
</style><div class="reflist">
<div class="mw-references-wrap mw-references-columns"><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */


.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}


/* end https://en.wikipedia.org/ */
</style><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.yourdictionary.com/endless-loop">"Endless loop dictionary definition"</a>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20200801213748/https://www.yourdictionary.com/endless-loop">Archived</a> from the original on 2020-08-01<span class="reference-accessdate">. Retrieved <span class="nowrap">2020-01-22</span></span>.</cite></span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://whatis.techtarget.com/definition/infinite-loop-endless-loop">"What is infinite loop (endless loop)"</a>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20190715101446/https://whatis.techtarget.com/definition/infinite-loop-endless-loop">Archived</a> from the original on 2019-07-15<span class="reference-accessdate">. Retrieved <span class="nowrap">2020-01-22</span></span>.</cite></span>
</li>
<li id="cite_note-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-3">^</a></b></span> <span class="reference-text"><cite id="CITEREFCaruso1999" class="citation news cs1">Caruso, Denise (August 16, 1999). <a rel="nofollow" class="external text" href="https://archive.nytimes.com/www.nytimes.com/library/tech/99/08/biztech/articles/16digi.html">"Overload of Hangers-On Creates Bumpy Ride for Internet Stocks"</a>. <i><a href="The_New_York_Times" title="The New York Times">The New York Times</a></i>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20191227145519/https://archive.nytimes.com/www.nytimes.com/library/tech/99/08/biztech/articles/16digi.html">Archived</a> from the original on December 27, 2019<span class="reference-accessdate">. Retrieved <span class="nowrap">December 27,</span> 2019</span>.</cite></span>
</li>
<li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text"><cite class="citation magazine cs1"><a rel="nofollow" class="external text" href="http://www.flowjournal.org/tag/loop-media/">"Codes and Modes: The Character of Documentary Culture"</a>. <i>Flow Journal</i>. November 2014. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20200801213624/http://www.flowjournal.org/tag/loop-media/?print=print-search">Archived</a> from the original on 2020-08-01<span class="reference-accessdate">. Retrieved <span class="nowrap">2020-01-23</span></span>. <q>an infinite loop is one that lacks .. an exit condition</q></cite></span>
</li>
<li id="cite_note-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-5">^</a></b></span> <span class="reference-text">also known as non-preemptive-multitasking: <cite class="citation magazine cs1"><a rel="nofollow" class="external text" href="https://www.pcmag.com/encyclopedia/term/48051/non-preemptive-multitasking">"Non-preemptive Multitasking"</a>. <i><a href="PC_Magazine" class="mw-redirect" title="PC Magazine">PC Magazine</a></i>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20190726232111/https://www.pcmag.com/encyclopedia/term/48051/non-preemptive-multitasking">Archived</a> from the original on July 26, 2019<span class="reference-accessdate">. Retrieved <span class="nowrap">February 7,</span> 2024</span>.</cite></span>
</li>
<li id="cite_note-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-6">^</a></b></span> <span class="reference-text"><cite id="CITEREFDavid_Hoag1976" class="citation web cs1">David Hoag (September 1976). <a rel="nofollow" class="external text" href="http://klabs.org/history/history_docs/mit_docs/1711.pdf">"The History of Apollo On-board Guidance, Navigation, and Control"</a> <span class="cs1-format">(PDF)</span>. Charles Stark Draper Laboratory. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20161105060425/http://klabs.org/history/history_docs/mit_docs/1711.pdf">Archived</a> <span class="cs1-format">(PDF)</span> from the original on 2016-11-05<span class="reference-accessdate">. Retrieved <span class="nowrap">2020-01-23</span></span>.</cite></span>
</li>
<li id="cite_note-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-7">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://nyxcrossword.com/2013/10/1013-13-new-york-times-crossword.html">"New York Times Crossword Answers"</a>. October 13, 2013. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20200802040416/https://nyxcrossword.com/2013/10/1013-13-new-york-times-crossword.html">Archived</a> from the original on August 2, 2020<span class="reference-accessdate">. Retrieved <span class="nowrap">January 22,</span> 2020</span>. <q>computing .. a defect .. which .. to loop</q></cite></span>
</li>
<li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.geeksforgeeks.org/halting-problem-in-theory-of-computation">"Halting Problem in Theory of Computation"</a>. 3 October 2018. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20200809100104/https://www.geeksforgeeks.org/halting-problem-in-theory-of-computation/">Archived</a> from the original on 9 August 2020<span class="reference-accessdate">. Retrieved <span class="nowrap">22 January</span> 2020</span>.</cite></span>
</li>
<li id="cite_note-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-9">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://pen-testing.sans.org/resources/papers/gcih/buffer-overflow-exploit-dameware-remote-control-software-104168">"A Buffer Overflow Exploit Against the DameWare Remote Control software"</a>. December 19, 2003. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20200724200739/https://pen-testing.sans.org/resources/papers/gcih/buffer-overflow-exploit-dameware-remote-control-software-104168">Archived</a> from the original on July 24, 2020<span class="reference-accessdate">. Retrieved <span class="nowrap">January 22,</span> 2020</span>. <q>As soon as the command shell is closed with a control-c combination ...</q></cite></span>
</li>
<li id="cite_note-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-10">^</a></b></span> <span class="reference-text"><a href="https://en.wikibooks.org/wiki/Ada_Programming/Control#Endless_Loop" class="extiw external" title="b:Ada Programming/Control">Ada Programming: Control: Endless Loop</a></span>
</li>
<li id="cite_note-11"><span class="mw-cite-backlink"><b><a href="#cite_ref-11">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://stackoverflow.com/questions/20186809/endless-loop-in-c-c">"Endless loop in C/C++"</a>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20160803202212/http://stackoverflow.com/questions/20186809/endless-loop-in-c-c">Archived</a> from the original on 2016-08-03.</cite></span>
</li>
<li id="cite_note-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-12">^</a></b></span> <span class="reference-text"><cite id="CITEREFLee_Dohm2013" class="citation web cs1">Lee Dohm (May 24, 2013). <a rel="nofollow" class="external text" href="https://www.lee-dohm.com/2013/05/24/alderson-loop">"Alderson loop"</a>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20200619200434/https://www.lee-dohm.com/2013/05/24/alderson-loop/">Archived</a> from the original on June 19, 2020<span class="reference-accessdate">. Retrieved <span class="nowrap">January 22,</span> 2020</span>.</cite></span>
</li>
<li id="cite_note-13"><span class="mw-cite-backlink"><b><a href="#cite_ref-13">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.catb.org/~esr/jargon/html/A/Alderson-loop.html">"Alderson Loop"</a>. <i><a href="The_Jargon_File" class="mw-redirect" title="The Jargon File">The Jargon File</a>, Version 4.4.7</i>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20060515053043/http://www.catb.org/~esr/jargon/html/A/Alderson-loop.html">Archived</a> from the original on 2006-05-15<span class="reference-accessdate">. Retrieved <span class="nowrap">2006-05-21</span></span>.</cite></span>
</li>
</ol></div></div>
<div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2></div>
<ul><li><a rel="nofollow" class="external text" href="http://www.programming-idioms.org/idiom/50/make-an-infinite-loop">Make an infinite loop</a> in several languages, on <a rel="nofollow" class="external text" href="http://www.programming-idioms.org/">programming-idioms.org</a>.</li></ul></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-08-01" href="https://en.wikipedia.org/wiki/?title=Infinite_loop&amp;oldid=1303662663">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>

</body></html>